Adopt webcore v0.1.0 (errors, crypto, UI components) - #155
Open
sarg3nt wants to merge 8 commits into
Open
Conversation
Repoint the 9 apperrors import sites to github.com/sarg3nt/webcore/core/errors and delete the now-duplicated internal/framework/errors. Adds webcore require + local replace directive. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Repoint services/crypto imports to webcore/core/crypto; main.go uses crypto.NewFromHashedKey (the legacy SHA-256 derivation) so existing at-rest encrypted data (server API keys, git PATs) still decrypts. Delete the duplicated internal package. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The internal/framework/ui package was 100% function-parity with webcore/ui/components (it's where they were extracted from). Repoint all 12 importers to webcore (aliased ui/templcomponents to preserve call sites), delete the duplicated package, regenerate templ. Also fix a crypto follow-up: agent_keyring test now uses crypto.NewFromHashedKey. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…om webcore Delete the duplicated component files from templates/components and re-export the moved funcs (InfoTooltip, Settings*, Table*, LiveRefresh*) + type aliases (SelectOption, TableConfig, TableColumn) as thin wrappers delegating to webcore/ui/components, so existing components.X call sites keep working with no churn and the markup is owned solely by webcore. Gearbox-only components (console, container_diagram, metrics/SystemMetrics, doughnut — coupled to metrics' unexported helpers) stay in the package. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two fixes from the adversarial review of the webcore adoption branch: 1. Module resolution: the local `replace => ../../webcore` with a fake v0.0.0 only resolved on the development machine — CI's single-repo checkout, Docker's `context: ./gearbox`, and `go install` all failed. webcore is now published and tagged, so pin the real github.com/sarg3nt/webcore v0.1.0 (go.sum hashes recorded) and drop the replace directive entirely. 2. Backport the events.Hub shutdown fixes to gearbox's own copy (the same bugs were fixed in webcore v0.1.0; gearbox still runs its own events package until that cutover): Subscribe deadlocked forever when called after Stop — reachable from the SSE handler on any shutdown race, pinning the HTTP goroutine — and Stop panicked on a second call. Subscribe now selects on done and returns a pre-closed Events channel (the SSE handler's !ok receive already handles it); Stop is sync.Once guarded. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Its only consumer (settings.templ) moved to webcore; the pages package has its own copy. Fixes the unused-func lint on PR #155. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR performs the first adoption pass of the shared github.com/sarg3nt/webcore module (pinned to v0.1.0) by switching Gearbox over to webcore’s core helpers (errors + crypto) and UI component library, while also backporting shutdown-race fixes to Gearbox’s own event hub.
Changes:
- Replace Gearbox’s internal
errorspackage withwebcore/core/errorsacross HTTP handlers (and remove the duplicated local implementation/tests). - Replace Gearbox’s internal AES-GCM encryptor with
webcore/core/crypto(including updating construction toNewFromHashedKey). - Move UI components to
webcore/ui/components, deleting local templ sources and adding a thintemplates/componentsre-export shim to keepcomponents.Xcall sites unchanged; also fixevents.Hubshutdown races (Stop()idempotent,Subscribe()non-blocking on shutdown).
Reviewed changes
Copilot reviewed 52 out of 53 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gearbox/internal/gears/home/widget_runner.go | Switch crypto import to webcore. |
| gearbox/internal/gears/home/handlers.go | Switch crypto import to webcore. |
| gearbox/internal/framework/ui/toggle.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/toast.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/table.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/modal.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/live_refresh.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/icons.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/collapsible.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/badge.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/ui/alerts.templ | Remove local UI component (now sourced from webcore). |
| gearbox/internal/framework/templates/pages/welcome.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/user_pages.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/overview.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/log_settings.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/haproxy_settings.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/haproxy_gear_settings.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/gears.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/backup.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/alert_rules.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/pages/admin_user_permissions.templ | Switch UI components import alias to webcore. |
| gearbox/internal/framework/templates/pages/admin_permissions.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/layouts/base.templ | Switch UI components import to webcore. |
| gearbox/internal/framework/templates/components/webcore_reexport.templ | Add templ wrappers re-exporting moved components from webcore. |
| gearbox/internal/framework/templates/components/webcore_reexport.go | Add type aliases to preserve components.* parameter types. |
| gearbox/internal/framework/templates/components/table.templ | Remove duplicated local component (now re-exported from webcore). |
| gearbox/internal/framework/templates/components/settings.templ | Remove duplicated local component (now re-exported from webcore). |
| gearbox/internal/framework/templates/components/live_refresh.templ | Remove duplicated local component (now re-exported from webcore). |
| gearbox/internal/framework/templates/components/info_tooltip.templ | Remove duplicated local component (now re-exported from webcore). |
| gearbox/internal/framework/services/server_adapter.go | Switch crypto import to webcore. |
| gearbox/internal/framework/services/crypto/encryption.go | Remove duplicated local encryptor implementation. |
| gearbox/internal/framework/services/auth_adapter.go | Switch crypto import to webcore. |
| gearbox/internal/framework/services/agent_keyring/rotator.go | Switch crypto import to webcore. |
| gearbox/internal/framework/services/agent_keyring/rotator_test.go | Update encryptor constructor to webcore API. |
| gearbox/internal/framework/handler/users.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/security.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/haproxy_config.go | Switch crypto import to webcore. |
| gearbox/internal/framework/handler/handler.go | Switch crypto import to webcore. |
| gearbox/internal/framework/handler/config.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/backup.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/api_traffic.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/api_services.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/api_logs.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/api_certificates.go | Switch errors import to webcore. |
| gearbox/internal/framework/handler/alerts.go | Switch errors import to webcore. |
| gearbox/internal/framework/events/hub.go | Make Stop() idempotent and avoid shutdown-race deadlock in Subscribe(). |
| gearbox/internal/framework/errors/errors.go | Remove duplicated local errors implementation (now webcore). |
| gearbox/internal/framework/errors/errors_writehttp_test.go | Remove local errors tests (now webcore-owned). |
| gearbox/go.sum | Add webcore + dependency version bumps. |
| gearbox/go.mod | Add webcore dependency and bump related deps. |
| gearbox/cmd/server/main.go | Switch encryptor construction to webcore NewFromHashedKey. |
| docs/webcore-extraction-plan.md | Add documentation describing extraction/adoption plan. |
- rotator_test: failure message said NewEncryptor; the call is NewFromHashedKey - go.mod: move the direct webcore dependency into the direct require block Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The canonical copy lives in the webcore repo (docs/webcore-extraction-plan.md); this stale duplicate also hardcoded contributor-specific paths, per review. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First adoption pass of the shared webcore library, pinned at the published
v0.1.0tag (no replace directive — CI/Docker resolve it from the module proxy).webcore/core/errors(9 handler import sites; deleted the duplicated internal package — byte-identical behavior)webcore/core/cryptoviaNewFromHashedKey, which reproduces the legacy SHA-256 key derivation exactly, so existing at-rest encrypted API keys / git PATs still decrypt (wire formatnonce||ciphertext||tagunchanged)webcore/ui/components: the wholeinternal/framework/uipackage (100% function parity — it's where webcore's components were extracted from) plus the duplicatedtemplates/componentsfiles (info_tooltip, settings, table, live_refresh) via a thin re-export shim, so all existingcomponents.Xcall sites compile unchanged while the markup is owned solely by webcoreSubscribedeadlocked forever when racingStop()— reachable from the SSE handler, pinning the HTTP goroutine — andStop()panicked on a second call)Kept in gearbox (deliberate): RBAC/auth (#148), events package (typed Publish API + SSE wire format), static JS/CSS (#149 — blocked on webcore#2 namespace renames), doughnut/metrics/console/container_diagram components.
Verification
go build ./...andgo test ./internal/...green against the published tagshowToastoperationalPart of the webcore adoption effort — follow-ups tracked in #148 (auth) and #149 (static assets).
🤖 Generated with Claude Code